package org.pf.base.pfStorages
{
	import flash.display.Sprite;
	import org.pf.base.pfGraphics.staff.DrawBitmap;
	import org.pf.base.pfGraphics.staff.PFImageGeometry;
	
	/**
	 * ...
	 * @author ...
	 */
	public class PFStorageImages
	{
		protected var _images:Array;
		protected var _imageNames:Array;
		protected var _imageGeometries:Array;
		protected var _imageClasses:Array;
		
		public function PFStorageImages(spriteNames:Array, spriteClasses:Array, spriteParams:Array)
		{
			_images = new Array();
			_imageGeometries = new Array();
			_imageNames = spriteNames;
			_imageClasses = spriteClasses;
			generate_geoms(spriteParams);
			generate_images();
		}
		
		private function generate_images():void
		{
			var img:Sprite = new Sprite();
			for (var i:int = 0; i < _imageClasses.length; i++)
			{			
				_images.push(DrawBitmap.MakeImage(_imageGeometries[i]));
			}
		}
		
		private function generate_geoms(params:Array):void
		{
			for (var i:int = 0; i < _imageNames.length; i++)
			{
				var geom:PFImageGeometry = new PFImageGeometry(_imageNames[i], params[i][0], params[i][1], params[i][2], params[i][3],_imageClasses[i]);
				_imageGeometries.push(geom);
			}
		}
		
		public final function getImage(name:String):Sprite
		{
			var tmp:Sprite;
			for (var i:int = 0; i < _imageNames.length; i++)
			{
				if (_imageNames[i] == name)
				{
					tmp=_images[i];
					break;
				}
			}
			return tmp;
		}
	
	}

}